package com.tianji.learning.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.common.domain.dto.PageDTO;
import com.tianji.common.domain.query.PageQuery;
import com.tianji.common.utils.UserContext;
import com.tianji.learning.domain.dto.LearningRecordFormDTO;
import com.tianji.learning.domain.po.LearningLesson;
import com.tianji.learning.domain.vo.LearningLessonVO;
import com.tianji.learning.service.ILearningLessonService;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学习记录表 前端控制器
 * </p>
 *
 * @author ffk
 * @since 2024-06-22
 */
@Api(tags = "学习记录接口")
@RestController
@RequestMapping("/learning-record")
@RequiredArgsConstructor
public class LearningRecordController {

    private final ILearningLessonService learningLessonService;
    private final ILearningRecordService learningLessonRecordService;

    /**
     * 提交学习记录
     */
    @ApiOperation("提交学习记录")
    @PostMapping()
    public void addLessonRecords(@RequestBody LearningRecordFormDTO learningRecordFormDTO){
        learningLessonRecordService.addLessonRecords(learningRecordFormDTO);
    }

    /**
     * 查询当前用户指定课程的学习进度
     * @param courseId 课程id
     * @return 课表信息、学习记录及进度信息
     */
    @ApiOperation("查询当前用户指定课程的学习进度")
    @GetMapping("/course/{courseId}")
    public LearningLessonDTO queryLearningRecordByCourse(@PathVariable("courseId") Long courseId){
        return learningLessonRecordService.queryLearningRecordByCourse(courseId);
    }

}
